<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>图书列表</title>
</head>
<style>
    a {
        text-decoration: none;
    }
</style>
<body>
<h1 style="color: blue">欢迎${sessionScope.user.name}登录[${sessionScope.user.usertype==1?"管理员":"普通用户"}]</h1>
<h1 style="text-align: center">图书详细信息列表</h1>
<form action="selectBooks" method="post">
    <table border="1" align="center" width="600px" cellpadding="0px" cellspacing="0px">
        <tr><td>
            作者:<input style="width: 100px" type="text" name="author" value="${author}"/>
            出版社:<input style="width: 100px" type="text" name="publish" value="${publish}"/>
            <input type="submit" value="查询"/></td></tr>
    </table>
</form>
<div align="center" style="color: black">
    <c:if test="${sessionScope.user.usertype==1}">
        <a href="addBooks">添加图书</a>
        &nbsp;&nbsp;&nbsp;&nbsp;
    </c:if>
    <a href="exit">退出</a>
</div>
<div></div>
<table align="center" width="800px" border="1px" cellpadding="0px" cellspacing="0px">
    <tr>
        <td>书名</td>
        <td>作者</td>
        <td>出版社</td>
        <td>出版时间</td>
        <td>页数</td>
        <td>价格</td>
        <td>内容摘要</td>
        <c:if test="${sessionScope.user.usertype==1}">
            <td>操作</td>
        </c:if>
    </tr>
    <c:forEach var="v" items="${requestScope.bookPageInfo.list}">
        <tr>
        <td>${v.name}</td>
        <td>${v.author}</td>
        <td>${v.publish}</td>
        <td><fmt:formatDate value="${v.publishdate}"></fmt:formatDate></td>
        <td>${v.page}</td>
        <td>${v.price}</td>
        <td>${v.content}</td>
        <c:if test="${sessionScope.user.usertype==1}">
            <td><a href="selectOneBook?bookId=${v.id}">修改</a> | <a href="javascript:" onclick="deleteBook('${v.id}')">删除</a></td>
            </tr>
        </c:if>

    </c:forEach>
</table>
<table width="800px" align="center">
    <tr>
        <td><a href="selectBooks?pageNo=1&author=${author}&publish=${publish}">首页</a></td>
        <td>
            <c:forEach var="v" items="${requestScope.bookPageInfo.navigatepageNums}">
                <a href="selectBooks?pageNo=${v}&author=${author}&publish=${publish}">${v}</a>
                &nbsp;
            </c:forEach>
        </td>
        <td>
            当前在第${requestScope.bookPageInfo.pageNum}页,共${requestScope.bookPageInfo.pages}页,
            共${requestScope.bookPageInfo.total}行
        </td>
        <td><a href="selectBooks?pageNo=${requestScope.bookPageInfo.pages}&author=${author}&publish=${publish}">尾页</a>
        </td>
    </tr>
</table>
<script type="text/javascript">
    function deleteBook(id) {
        var r = window.confirm("确认删除吗?删除后数据无法恢复");
        if(r == true){
            window.location.href="deleteBook?bookId="+id;
        }
    }
</script>
</body>
</html>
